package com.infy.olt.action;

import java.util.Date;
import java.util.List;

import com.infy.olt.dto.EmpDtl;
import com.infy.olt.service.TableConfigurationService;
import com.opensymphony.xwork2.ActionSupport;

public class OnCallTrackerAction extends ActionSupport{
	
	private TableConfigurationService tableConfigurationService;
	
	/**
	 * @return the tableConfigurationService
	 */
	public TableConfigurationService getTableConfigurationService() {
		return tableConfigurationService;
	}

	/**
	 * @param tableConfigurationService the tableConfigurationService to set
	 */
	public void setTableConfigurationService(
			TableConfigurationService tableConfigurationService) {
		this.tableConfigurationService = tableConfigurationService;
	}
	
	private String fileNumber;
	
	private String userName;
	
	private String role;
	
	private String reportingMgr;
	
	private String ibu;
	
	private String subCluster;
	
	private List month;
	
	private String onCallDetails;
	
	private String remarks;
	
	private String startDate;
	
	private String endDate;
	
	private String startHrs;
	
	private String endHrs;
	
	private String totalHrs;
	

	/**
	 * @return the fileNumber
	 */
	public String getFileNumber() {
		return fileNumber;
	}

	/**
	 * @param fileNumber the fileNumber to set
	 */
	public void setFileNumber(String fileNumber) {
		this.fileNumber = fileNumber;
	}

	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * @return the role
	 */
	public String getRole() {
		return role;
	}

	/**
	 * @param role the role to set
	 */
	public void setRole(String role) {
		this.role = role;
	}

	/**
	 * @return the reportingMgr
	 */
	public String getReportingMgr() {
		return reportingMgr;
	}

	/**
	 * @param reportingMgr the reportingMgr to set
	 */
	public void setReportingMgr(String reportingMgr) {
		this.reportingMgr = reportingMgr;
	}

	/**
	 * @return the ibu
	 */
	public String getIbu() {
		return ibu;
	}

	/**
	 * @param ibu the ibu to set
	 */
	public void setIbu(String ibu) {
		this.ibu = ibu;
	}

	/**
	 * @return the subCluster
	 */
	public String getSubCluster() {
		return subCluster;
	}

	/**
	 * @param subCluster the subCluster to set
	 */
	public void setSubCluster(String subCluster) {
		this.subCluster = subCluster;
	}

	/**
	 * @return the month
	 */
	public List getMonth() {
		return month;
	}

	/**
	 * @param month the month to set
	 */
	public void setMonth(List month) {
		this.month = month;
	}

	/**
	 * @return the onCallDetails
	 */
	public String getOnCallDetails() {
		return onCallDetails;
	}

	/**
	 * @param onCallDetails the onCallDetails to set
	 */
	public void setOnCallDetails(String onCallDetails) {
		this.onCallDetails = onCallDetails;
	}

	/**
	 * @return the remarks
	 */
	public String getRemarks() {
		return remarks;
	}

	/**
	 * @param remarks the remarks to set
	 */
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	
	/**
	 * @return the startDate
	 */
	public String getStartDate() {
		return startDate;
	}

	/**
	 * @param startDate the startDate to set
	 */
	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	/**
	 * @return the endDate
	 */
	public String getEndDate() {
		return endDate;
	}

	/**
	 * @param endDate the endDate to set
	 */
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	/**
	 * @return the startHrs
	 */
	public String getStartHrs() {
		return startHrs;
	}

	/**
	 * @param startHrs the startHrs to set
	 */
	public void setStartHrs(String startHrs) {
		this.startHrs = startHrs;
	}

	/**
	 * @return the endHrs
	 */
	public String getEndHrs() {
		return endHrs;
	}

	/**
	 * @param endHrs the endHrs to set
	 */
	public void setEndHrs(String endHrs) {
		this.endHrs = endHrs;
	}

	/**
	 * @return the totalHrs
	 */
	public String getTotalHrs() {
		return totalHrs;
	}

	/**
	 * @param totalHrs the totalHrs to set
	 */
	public void setTotalHrs(String totalHrs) {
		this.totalHrs = totalHrs;
	}

	public String getEmpDetails(){
		EmpDtl empDtl = tableConfigurationService.getEmployeeDetails("V043068");
		this.fileNumber = empDtl.getFileID();
		this.ibu = empDtl.getIbu();
		this.reportingMgr = empDtl.getReportingMgr();
		this.role = empDtl.getRole();
		this.userName = empDtl.getResourceName();
		this.subCluster = empDtl.getSubCluster();		
		return SUCCESS;
	}

	public String updateOncallDetails(){
		//addActionMessage("Updated Data Successfully"); 10/02/2011
		System.out.println("ibu: "+this.userName);
		String startDt = this.startDate;
		String startHrs = this.startHrs;
		String endDt = this.endDate;
		String endHrs = this.endHrs;
		
		String startDate = startDt +" "+ startHrs;
		String endDate = endDt +" "+endHrs;
		
		int result = tableConfigurationService.updateOncallDetails(this.onCallDetails, this.remarks, 
				startDate, endDate, this.totalHrs, this.subCluster, this.ibu, this.userName);
		
		if(result == 1){
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
	
}
